﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;

namespace Image_Test1
{
    public partial class ResultsForm : Form
    {
        public ResultsForm()
        {
            InitializeComponent();
        }
        public void Init (Bitmap Result)
        {
            Result_PicBox.Image = Result;
            //this.BackgroundImage = Result;
            this.Width = Result.Width+17;
            this.Height = Result.Height+39;
        }

        private void Result_PicBox_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            SaveFileDialog.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
            SaveFileDialog.Title = "Save an Image File";


            if (SaveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK && SaveFileDialog.FileName != "")
            {
                try
                {
                    using (Bitmap bitmap = new Bitmap(Result_PicBox.Image))
                    {
                        bitmap.Save(SaveFileDialog.FileName, ImageFormat.Jpeg);
                    }
                    MessageBox.Show("Picture Saved Successfully.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An Error has occured: \n" + ex.Message);
                }
            }
            else
                MessageBox.Show("Error");
        }
    }
}
